package com.gxuwz.com_property.utils;

import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.ThreadLocalRandom;

@Component
public class RamdomUtils {

    public long generateId() {
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMdd");
        String currentDate = dtf.format(LocalDateTime.now());

        int randomNum = ThreadLocalRandom.current().nextInt(10000, 99999);
        String idStr = currentDate + randomNum;

        return Long.parseLong(idStr);
    }
}
